﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ECCIT;
using OgilvyOne.UKNow.Model;
using OgilvyOne.UKNow.IDAL;
using OgilvyOne.UKNow.DALFactory;

namespace OgilvyOne.UKNow.BLL
{
    public class NewsUserBLL
    {
        public int LanguageID { get; set; }
        public NewsUserBLL(int langID)
        {
            this.LanguageID = langID;
        }
        #region 操作数据
        /// <summary>
        /// 保存/修改数据
        /// </summary>
        /// <param name="modelInfo">新闻用户实体类</param>
        /// <returns>
        ///     通过判断ResultInfo.Result为true还是false获取保存是否成功
        ///     如果ResultInfo.Result为true，可以通过ResultInfo.ReturnedObject获取modelInfo
        ///     如果ResultInfo.Result为false，可以通过ResultInfo.Message获取错误提示，通过ResultInfo.Exception获取异常信息
        /// </returns>
        public ResultInfo Save(NewsUserModel info)
        {
            return NewsUserDALFactory.Create(LanguageID).Save(info);
        }

        /// <summary>
        /// 设置用户是否有效 
        /// </summary>
        /// <param name="id">用户id</param>
        /// <param name="flag">标识位 真值：有效 假值：无效</param>
        /// <returns></returns>
        public ResultInfo SetStatus(int id)
        {
            bool flag = false;
            if (NewsUserDALFactory.Create(LanguageID).GetNewsUserModelByID(id).Status == 0)
                flag = true;
            return NewsUserDALFactory.Create(LanguageID).SetStatus(id, flag);
        }


        public IList<NewsUserModel> CheckName(string name)
        {
            return NewsUserDALFactory.Create(LanguageID).CheckName(name);
        }
        #endregion

        #region 获取数据
        /// <summary>
        /// 获取所有用户数据
        /// </summary>
        /// <returns>返回泛型集合</returns>
        public IList<NewsUserModel> GetNewsUserModel()
        {
            return NewsUserDALFactory.Create(LanguageID).GetNewsUserModel();
        }
        #endregion
    }
}
